package main;

import java.util.Stack;

public class MotorCautare {
protected final int MAX=100;//stocheaza nr maxim de rute
protected Ruta rute []= new Ruta [MAX];
protected int nrRute=0;
Stack btStack=new Stack();//stiva va retine solutia finala

public void adaugaRuta(String p, String d, int dist,boolean rutier, boolean feroviar, boolean fluvial){
	if(nrRute<MAX){
		Ruta z=new Ruta(p,d,dist,rutier,feroviar,fluvial);
	rute[nrRute]=z;
	nrRute++;
    }
	else System.out.println ("Nu mai poate fi adaugat nici o ruta");
}
	public void setup (){
		adaugaRuta (" Timisoara ","Foeni" ,40 , true,false ,false ) ;
		adaugaRuta (" Timisoara ","Jebel" ,25 , true,true ,false ) ;
		adaugaRuta ("Foeni" ,"Ciacova" ,20, true , false ,false) ;
		adaugaRuta (" Ciacova ","Jebel" ,10 , true,false ,false );
		adaugaRuta ("Jebel","Deta" ,12 , true,true,false ) ;
		adaugaRuta ("Ciacova","Deta" ,12 , true,false ,false ) ;
		adaugaRuta ("Deta" ,"Vrsac" ,30, true , false ,false) ;
		adaugaRuta (" Vrsac","Panceva" ,80, true,false ,false ) ;
		
		adaugaRuta (" Timisoara ","Aradu Nou" ,48 , true,true ,false ) ;
		adaugaRuta ("Aradu Nou" ,"Lipova" ,18, true , true ,false) ;
		
		adaugaRuta (" Timisoara ","Giarmata" ,10 , true,true ,false ) ;
		adaugaRuta ("Giarmata" ,"Lipova" ,40, true , true ,false) ;
		
		adaugaRuta ("Giarmata" ,"Ianova" ,7, true , false ,false) ;
		
		adaugaRuta ("Ianova" ,"Recas" ,15, true , false ,false) ;
		
		adaugaRuta (" Timisoara ","Recas" ,20 , true,true ,false ) ;
		adaugaRuta ("Recas" ,"Topolovat" ,20, true , true ,false) ;
		adaugaRuta (" Topolovat","Lugoj" ,10 , true,true ,false ) ;
		adaugaRuta (" Lugoj","Caransebes" ,50 , true,true ,false ) ;
		adaugaRuta ("Caransebes" ,"Mehadia" ,70, true , true ,false) ;
		adaugaRuta (" Mehadia ","Orsova" ,20 , true,true ,false ) ;
		adaugaRuta (" Orsova ","Moldova Noua" ,10 , true,false ,true ) ;
		adaugaRuta (" Moldova Noua ","Panceva" ,10 , false,true ,false ) ;
		
		//mai trebuie
		}

	 public int match (String plecare , String destinatie ){//cauta daca exista rute directe intre 2 orase si ret dist
		 int dist=0;
		 for (int i=0;i<nrRute;i++){
			  if(rute[i].localitatePlecare.equals (plecare) && rute[i].localitateSosire.equals (destinatie) && rute[i].skip==false)
			  {
				  dist=rute[i].distanta;
				  rute[i].skip=true ;
				   }
				  }
				   return dist ;
				  }
	 
	 Ruta find ( String from) {//identifica toate rutele ce pornesc dintr-o loc
		 Ruta r=null ;
		 for (int i=0;i<nrRute;i++){
			 if(rute[i].localitatePlecare.equals ( rute[i].localitatePlecare)&&rute[i].skip==false) {
				 r=new Ruta (rute[i].localitatePlecare, rute[i].localitateSosire, rute[i].distanta , rute[i].isRutier() ,rute[i].isFluvial() ,rute[i].isFeroviar()) ;
		 }
		 }
		  return r ;
		 }	
	 void calculRuta ( String from , String to ) {//det drumul dintre 2 loc
		 int dist;
		 Ruta z ;
}
	 
	 
}
